package com.company.genealogy.web.controller;

import com.company.genealogy.web.dto.MemberAuditQueryDTO;
import com.company.genealogy.web.dto.AuditActionDTO;
import com.company.genealogy.web.service.MemberAuditService;
import com.company.genealogy.web.vo.MemberAuditVO;
import com.company.genealogy.common.result.ApiResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

@RestController
@RequestMapping("/api/v1/audit/member")
public class MemberAuditController {
    @Autowired
    private MemberAuditService memberAuditService;

    @GetMapping("/list")
    public ApiResponse<Page<MemberAuditVO>> list(MemberAuditQueryDTO query) {
        return ApiResponse.success(memberAuditService.pageList(query));
    }

    @GetMapping("/stats")
    public ApiResponse<Map<String, Integer>> stats(MemberAuditQueryDTO query) {
        return ApiResponse.success(memberAuditService.stats(query));
    }

    @PostMapping("/approve")
    public ApiResponse<Void> approve(@RequestBody AuditActionDTO dto) {
        memberAuditService.approve(dto);
        return ApiResponse.success();
    }

    @PostMapping("/reject")
    public ApiResponse<Void> reject(@RequestBody AuditActionDTO dto) {
        memberAuditService.reject(dto);
        return ApiResponse.success();
    }
}